#include "kfs_time.hpp"

uint64_t KfsTime::timeNow()
{
    struct timespec timeNow;
    uint64_t timeNowNsec;
    if(clock_gettime(CLOCK_REALTIME, &timeNow) == 0)
    {
        timeNowNsec = toNanosec(timeNow);
    }
    else
    {
        time_t timeNowSec = time(0);
        if(timeNowSec != -1)
            timeNowNsec = (uint64_t)timeNowSec * 1000000000;
        else
            timeNowNsec = 0;
    }
    return timeNowNsec;
}
